package com.ruihu.admin.module.business.tasknode.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruihu.admin.module.business.tasknode.domain.dto.SubTaskNodeInstDTO;
import com.ruihu.admin.module.business.tasknode.domain.entity.SubTaskNodeInstEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *  [ 子任务环节实例表 ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c) 瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date  2022-08-30 19:43:58
 * @since JDK1.8
 */
@Data
public class SubTaskNodeInstVO {

    @ApiModelProperty("主键")
    private Long id;

    @ApiModelProperty("子任务ID")
    private Long subTaskId;

    @ApiModelProperty("子任务状态")
    private Integer subTaskStatus;

    @ApiModelProperty("任务节点ID")
    private Long taskNodeId;

    @ApiModelProperty("任务环节实例ID")
    private Long taskNodeInstId;

    @ApiModelProperty("任务环节名称")
    private String taskNodeName;

    @ApiModelProperty("任务环节序号")
    private Integer sortNo;

    @ApiModelProperty("缺陷类型列表")
    private List<DefectTypeVO> defectTypeList;

    @ApiModelProperty("电芯类型编号")
    private String cellTypeCode;

    @ApiModelProperty("电芯类型编号名称")
    private String cellTypeName;

    @ApiModelProperty("工厂编码")
    private String factoryCode;

    @ApiModelProperty("工厂名称")
    private String factoryName;

    @ApiModelProperty("备注信息")
    private String remark;

    @ApiModelProperty("任务节点配置和数据")
    private List<NodeInstProcessVO> nodeInstConfigValueList;

    @ApiModelProperty("文件列表")
    private List<TaskNodeFileVO> taskNodeFileList = new ArrayList<>();

    @ApiModelProperty("完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date completionTime;

    @ApiModelProperty("创建人姓名")
    private String createByName;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty("拆解人")
    private String taskOwner;

    @ApiModelProperty("拆解部门")
    private String taskDepartment;

    @ApiModelProperty("任务拆解时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date taskBeginTime;

    public static SubTaskNodeInstVO convertToSubTaskNodeInstVO(SubTaskNodeInstEntity entity) {
        if (entity == null) {
            return null;
        }
        SubTaskNodeInstVO subTaskNodeInstVO = new SubTaskNodeInstVO();
        subTaskNodeInstVO.setSubTaskId(entity.getSubTaskId());
        subTaskNodeInstVO.setTaskNodeInstId(entity.getTaskNodeInstId());
        subTaskNodeInstVO.setCellTypeCode(entity.getCellTypeCode());
        subTaskNodeInstVO.setFactoryCode(entity.getFactoryCode());
        subTaskNodeInstVO.setRemark(entity.getRemark());
        subTaskNodeInstVO.setCompletionTime(entity.getCompletionTime());
        subTaskNodeInstVO.setId(entity.getId());
        subTaskNodeInstVO.setUpdateTime(entity.getUpdateTime());
        subTaskNodeInstVO.setCreateTime(entity.getCreateTime());
        return subTaskNodeInstVO;
    }

    public static SubTaskNodeInstVO convertToSubTaskNodeInstVO(SubTaskNodeInstDTO subTaskNodeInstDTO) {
        if (subTaskNodeInstDTO == null) {
            return null;
        }
        SubTaskNodeInstVO subTaskNodeInstVO = new SubTaskNodeInstVO();
        subTaskNodeInstVO.setId(subTaskNodeInstDTO.getId());
        subTaskNodeInstVO.setSubTaskId(subTaskNodeInstDTO.getSubTaskId());
        subTaskNodeInstVO.setSubTaskStatus(subTaskNodeInstDTO.getSubTaskStatus());
        subTaskNodeInstVO.setTaskNodeId(subTaskNodeInstDTO.getTaskNodeId());
        subTaskNodeInstVO.setTaskNodeInstId(subTaskNodeInstDTO.getTaskNodeInstId());
        subTaskNodeInstVO.setTaskNodeName(subTaskNodeInstDTO.getTaskNodeName());
        subTaskNodeInstVO.setSortNo(subTaskNodeInstDTO.getSortNo());
        subTaskNodeInstVO.setCellTypeCode(subTaskNodeInstDTO.getCellTypeCode());
        subTaskNodeInstVO.setFactoryCode(subTaskNodeInstDTO.getFactoryCode());
        subTaskNodeInstVO.setCreateTime(subTaskNodeInstDTO.getCreateTime());
        subTaskNodeInstVO.setUpdateTime(subTaskNodeInstDTO.getUpdateTime());
        subTaskNodeInstVO.setTaskBeginTime(subTaskNodeInstDTO.getTaskBeginTime());
        subTaskNodeInstVO.setRemark(subTaskNodeInstDTO.getRemark());
        subTaskNodeInstVO.setCompletionTime(subTaskNodeInstDTO.getCompletionTime());
        return subTaskNodeInstVO;
    }

}
